package com.suixinsanren.design.iterator.demo02;


public class Waitress {

    private DinerMenu dinerMenu;
    private PancakeHouseMenu pancakeHouseMenu;

    public Waitress(DinerMenu dinerMenu, PancakeHouseMenu pancakeHouseMenu) {
        this.dinerMenu = dinerMenu;
        this.pancakeHouseMenu = pancakeHouseMenu;
    }

    public void printMenu() {
        printMenu(dinerMenu.iterator());
        System.out.println("---------------------");
        printMenu(pancakeHouseMenu.iterator());
    }

    private void printMenu(Iterator<MenuItem> iterator) {
        while (iterator.hasNext()) {
            MenuItem item = iterator.next();
            System.out.println(item.getName() + "\t" + item.getDescription() + "\t" + item.getPrice());
        }
    }
}
